﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AlternativePorts
{
	public class Causality : IDisposable
	{
		[ThreadStatic]
		private static Causality currentCausality;

		public static Causality Current
		{
			get { return currentCausality; }
		}

		public Port<Exception> ErrorPort { get; set; }
		public IPort CoordinationPort { get; set; }

		public Causality(Port<Exception> errorPort) : this(errorPort, null)
		{
		}

		public Causality(Port<Exception> errorPort, IPort coordinationPort)
		{
			this.ErrorPort = errorPort;
			this.CoordinationPort = coordinationPort;
			currentCausality = this;
		}

		public void Dispose()
		{
			currentCausality = null;
		}
	}
}
